package com.zrrd.jt_admin.set.express.controller;


import com.zrrd.jt_admin.common.entity.ExpressValue;
import com.zrrd.jt_admin.common.response.ResponseResult;
import com.zrrd.jt_admin.set.express.service.ExpressValueService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Zhangyk
 * @since 2024-07-02
 */
@Api(tags = "运费模板策略-接口文档")
@RestController
@RequestMapping("admin/expressValue")
@ResponseBody
public class ExpressValueController {
    @Resource
    private ExpressValueService expressValueService;

    @ApiOperation(value = "二、增加运费模板策略")
    @PostMapping
    public ResponseResult addExpressValue(@RequestBody ExpressValue expressValue) {
        if (expressValue==null){
            return ResponseResult.queryResponse(false);
        }
        return ResponseResult.queryResponse(expressValueService.save(expressValue));
    }

    @ApiOperation(value = "三、修改运费模板策略")
    @PutMapping
    public ResponseResult updateExpressValue(@RequestBody ExpressValue expressValue) {
        if (expressValue==null){
            return ResponseResult.updateResponse(false);
        }
        return ResponseResult.updateResponse(expressValueService.updateById(expressValue));
    }

    @ApiOperation(value = "四、删除运费模板策略")
    @DeleteMapping("{id}/delete")
    public ResponseResult deleteExpressValue(@PathVariable Integer id) {
        return ResponseResult.queryResponse(expressValueService.removeById(id));
    }


}

